package four;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/2333")
public class DemoServlet extends HttpServlet {
    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        resp.setContentType("text/html;charset=UTF-8");

        String username=req.getParameter("username");    //拿到表单中的数据
        String password=req.getParameter("password");

        if(username.length()>0&&password.length()>0){
            resp.getWriter().println("用户名："+username);
            resp.getWriter().println("<br>");
            resp.getWriter().println("密码："+password);
            resp.getWriter().println("<br>");
            resp.getWriter().println("注册成功");
        }else if(username.isEmpty()&&password.length()>0){
            resp.getWriter().println("用户名为空");
        }else if(password.isEmpty()&&username.length()>0){
            resp.getWriter().println("密码为空");
        }else if(password.isEmpty()&&username.isEmpty()){
            resp.getWriter().println("用户和密码为空");
        }
    }
}
